package cn.iocoder.yudao.module.resource.service.tag;

import cn.iocoder.yudao.module.resource.dal.dataobject.tag.ResourceTagDO;
import cn.iocoder.yudao.module.resource.dal.mysql.tag.ResourceTagMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;

/**
 * 资源标签 Service 实现类
 *
 * @author 芋道源码
 */
@Service
@Validated
@Slf4j
public class ResourceTagServiceImpl implements ResourceTagService {

    @Resource
    private ResourceTagMapper tagMapper;

    @Override
    public Long createTag(ResourceTagDO tagDO) {
        tagMapper.insert(tagDO);
        return tagDO.getId();
    }

    @Override
    public void updateTag(ResourceTagDO tagDO) {
        tagMapper.updateById(tagDO);
    }

    @Override
    public void deleteTag(Long id) {
        tagMapper.deleteById(id);
    }

    @Override
    public ResourceTagDO getTag(Long id) {
        return tagMapper.selectById(id);
    }

    @Override
    public List<ResourceTagDO> getTagList() {
        return tagMapper.selectList();
    }

    @Override
    public ResourceTagDO getTagByName(String name) {
        return tagMapper.selectByName(name);
    }

    @Override
    public List<ResourceTagDO> getTagListByStatus(Integer status) {
        // 标签没有status字段，返回所有标签
        return tagMapper.selectList();
    }

}
